package com.bdqn.easybuy1.utils;

import com.bdqn.easybuy1.entities.Product;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@Getter
@Setter
public class ShoppingCartItem implements Serializable {
    /**
     * 加入购物车的商品
     */
    private Product product;
    /**
     * 加入购物车的商品的数量
     */
    private Integer quantity;
    /**
     * 加入购物车的商品的总价
     */
    private float cost;

    public ShoppingCartItem(Product product, Integer quantity) {
        this.product = product;
        this.quantity = quantity;
        this.cost = product.getPrice() * quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
        this.cost = product.getPrice() * quantity;
    }
}
